import java.io.IOException;
import java.util.HashMap;


/**
 * Created with IntelliJ IDEA.
 * Description: TCP词典翻译服务器
 */
public class TcpThreadPoolDictServer extends TcpThreadPoolEchoServer{

    private HashMap<String, String> dict = new HashMap<>();

    public TcpThreadPoolDictServer(int port) throws IOException {
        super(port);
        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "该词无法被翻译");
    }

    public static void main(String[] args) throws IOException {
        TcpThreadPoolDictServer tcpThreadPoolDictServer = new TcpThreadPoolDictServer(9090);
        tcpThreadPoolDictServer.start();
    }
}
